package com.itheima.thread.threadpool.demo02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;


public class ThreadPoolDemo04 {

    public static void main(String[] args) {

        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();

//        scheduledExecutorService.schedule(() -> System.out.println(Thread.currentThread().getName() + "任务执行了..."), 5, TimeUnit.SECONDS);

        scheduledExecutorService.scheduleAtFixedRate(() -> System.out.println(Thread.currentThread().getName() + "任务执行了...")
                                                     , 5, 2, TimeUnit.SECONDS);

//        scheduledExecutorService.shutdown();

    }

}
